package com.invengo.module_check;


import androidx.databinding.BindingAdapter;


import com.scwang.smart.refresh.layout.SmartRefreshLayout;

import me.goldze.mvvmhabit.binding.command.BindingCommand;

public class ViewAdapter {


    @BindingAdapter(value = {"refresh", "loadMore", "enableLoadmore"}, requireAll = false)
    public static void setLoad(final SmartRefreshLayout layout, final BindingCommand refresh, final BindingCommand loadMore, final boolean enableLoadmore) {
        layout.setOnRefreshListener(refreshLayout -> {
            if (refresh != null)
                refresh.execute();
        });
        layout.setOnLoadMoreListener(refreshLayout -> {
            if (loadMore != null) {
                loadMore.execute();
            }
        });
        layout.setEnableLoadMore(enableLoadmore);
    }


}
